package com.zk.algorithm.tree;

import com.zk.algorithm.annotation.Easy;
import com.zk.algorithm.annotation.LeetCodeExplore;
import com.zk.algorithm.bean.TreeNode;

/**
 * 最大深度
 *
 * @author zk
 */
@LeetCodeExplore
@Easy
public class MaxmiumDepthOfBinaryTree {

    public int maxDepth(TreeNode root) {
        return root == null ?
                0 :
                // 最后总是要加 1
                Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }

}
